class Solution(object):
    def maximumPrimeDifference(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        # 初始化一个一百以内的素数筛
        prime_filter = [1] * 101
        # 0和1都不是素数
        prime_filter[0] = 0
        prime_filter[1] = 0
        # 填充素数筛（100以内）
        for i in range(2, 101):
            if prime_filter[i]:
                fact = 2
                while True:
                    if i * fact <= 100:
                        prime_filter[i*fact] = 0
                        fact += 1
                    else:
                        break
        length = len(nums)
        left = 0
        right = length - 1
        for i in range(length):
            if prime_filter[nums[i]]:
                left = i
                break
        for i in range(length):
            if prime_filter[nums[length-1-i]]:
                right = length-1-i
                break
        return right - left